<?php

/**
 * Created by PhpStorm.
 * User: fanfz_000
 * Date: 2015/4/7 0007
 * Time: 17:15
 * 作用 ：回复控制器
 */
class Reply extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }

    //word详细信息
    function index()
    {
        $this->load->helper('smiley');
        $this->load->library('table');
        //缓存60分钟更新一次
        $this->output->cache(60);

        //模型操作，图片轮播图片列表
        $this->load->model('Backgroudurl_model', 'image', TRUE);
        $data['image_list'] = $this->image->show_image_list();

        //模型操作,标签云
        $this->load->model('Label_model', 'label', TRUE);
        $data['label_list'] = $this->label->show_label_list();

        //模型操作,文章列表
        $this->load->model('Word_model', 'word', TRUE);
        $data['word_list'] = $this->word->show_word_list(0, 10);

        //模型操作,友情链接
        $this->load->model('Friendhref_model', 'friend_href', TRUE);
        $data['friend_list'] = $this->friend_href->show_friend_href_list();

        //页面加载
        $this->load->view('header', $data);
        $this->load->view('reply_header');
        $this->load->view('reply');
        $this->load->view('reply_aside');
        $this->load->view('footer');
    }

    //新建留言
    function reply_create()
    {
        $reply_text = $this->input->post('reply_text');
        //模型操作,回复
        $this->load->model('Reply_model', 'reply', TRUE);
        $data = $this->reply->create_reply($reply_text);
        echo json_encode($data);
    }

    //显示留言
    function reply_page()
    {
        $page = $this->input->post('page');
        $limit = $this->input->post('limit');
        //模型操作,回复
        $this->load->model('Reply_model', 'reply', TRUE);
        $data = $this->reply->show_reply($page, $limit);
        echo json_encode($data);
    }

    /*删除留言 2015-05-09*/
    function delete_reply()
    {
        $Id = $this->input->post('Id');
        //模型操作,回复
        $this->load->model('Reply_model', 'reply', TRUE);
        $data = $this->reply->delete_reply($Id);
        echo json_encode($data);
    }
}